package com.dao.green.cn.test01.uis.activities;

import android.databinding.DataBindingUtil;
import android.support.v7.widget.LinearLayoutManager;

import com.dao.green.cn.applibary.base.BaseActivity;
import com.dao.green.cn.test01.R;
import com.dao.green.cn.test01.beans.RecyclerTestBean;
import com.dao.green.cn.test01.databinding.AcRecycleLayoutBinding;
import com.dao.green.cn.test01.uis.adapters.RecyclerTestAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Ant on 2017/8/28  9:55
 * <p>
 * <p>
 *
 * @version 1.0.0
 * @auther Ant
 */

public class RecyclerViewTest extends BaseActivity {
    private AcRecycleLayoutBinding binding;

    private List<RecyclerTestBean> data;
    private RecyclerTestAdapter adapter;

    @Override
    public void createBinding() {
        data = new ArrayList<>();
        binding = DataBindingUtil.setContentView(this, R.layout.ac_recycle_layout);
    }

    @Override
    public void initView() {

        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);


        binding.recycleListView.setLayoutManager(linearLayoutManager);
        binding.recycleListView.setHasFixedSize(true);
        adapter = new RecyclerTestAdapter(this);
        binding.recycleListView.setAdapter(adapter);

    }

    @Override
    public void initData() {
        RecyclerTestBean bean = null;
        data.clear();
        for (int i = 0; i < 20; i++) {
            bean = new RecyclerTestBean();
            bean.setId(i);
            bean.setName("item " + i);
            data.add(bean);
        }

        adapter.setData(data);
    }

    @Override
    public void initListener() {

    }


}
